package com.xc.springsecurity.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String hello(Authentication authentication) {
        return "hello  "+authentication.getName();
    }

    @RequestMapping("/index")
    public String index() {
        String name= SecurityContextHolder.getContext().getAuthentication().getName();
        return "index  "+name;
    }

}
